<template>
	<view class="waterfall-item-container">
		<view class="waterfall-item" @tap="onTap">
			<image :src="params.mainImage" mode="widthFix" @load="emitHeight" @error="emitHeight"></image>
			<view class="content-water">
				<view class="title">{{params.hotelName}}</view>
				<!-- <view class="money">￥{{params.startingPrice}}元</view> -->
				<view class="star-lines">
					<uni-rate size="16" readonly active-color="#EF5233" :value="5" />
					<view class="start-text">{{params.avgScore}}</view>
				</view>
				<view class="price-lines">
					<view class="price1"><text>￥</text>{{params.startingPrice}}</view>
					<view class="price2">元<text>起</text></view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name:"helangWaterfallItem",
		options:{
			virtualHost: true
		},
		props:{
			params:{
				type: Object,
				default(){
					return {}
				}
			},
			tag:{
				type:String | Number,
				default:''
			},
			index:{
				type:Number,
				default:-1
			}
		},
		data() {
			return {
				
			};
		},
		methods:{
			// 发出组件高度信息，在此处可以区分正确和错误的加载，给予错误的提示图片
			emitHeight(e){
				const query = uni.createSelectorQuery().in(this);
				query.select('.waterfall-item-container').boundingClientRect(data => {
					let height = Math.floor(data.height);
					this.$emit("height",height,this.$props.tag);
				}).exec();
			},
			onTap(){
				this.$emit("click",this.$props.index,this.$props.tag);
			}
		}
	}
</script>

<style lang="scss" scoped>
.waterfall-item{
	// padding: 16rpx;
	background-color: #fff;
	border-radius: 4px;
	font-size: 28rpx;
	color: #666;
	
	image{
		display: block;
		width: 100%;
		// 默认设置一个图片的大约值
		height: 350rpx;
		border-radius: 10rpx;
	}
	.content-water{
		margin-top: -10rpx;
		border-bottom-left-radius: 10rpx;
		border-bottom-right-radius: 10rpx;
		border: 1rpx solid #EFEFEF;
		padding: 10rpx;
		border-top: 0;
		.title{
			font-size: 32rpx;
			font-weight: 500;
			color: #2A2B2E;
			line-height: 40rpx;
		}
		.money{
			color: #fa3534;
			margin-top: 8rpx;
		}
		
		.label{
			background-color: #fa3534;
			color: #fff;
			font-size: 20rpx;
			padding: 4rpx 16rpx;
			border-radius: 20rpx;
		}
		
		.shop-name{
			font-size: 20rpx;
			color: #999;
		}
		.star-lines {
			display: flex;
			align-items: center;
			font-size: 24rpx;
			font-weight: 600;
			color: #EF5233;
			line-height: 33rpx;
			margin-top: 10rpx;
		
			.start-text {
				margin-left: 14rpx;
			}
		}
		
		.price-lines {
			width: 100%;
			display: flex;
			align-items: center;
			justify-content: flex-end;
			margin-top: 13rpx;
		
			.price1 {
				font-size: 33rpx;
				font-family: PingFangSC, PingFang SC;
				font-weight: 600;
				color: #EF5233;
				line-height: 33rpx;
		
				text {
					font-size: $uni-font-size-base;
					font-weight: normal;
				}
			}
		
			.price2 {
				font-size: $uni-font-size-sm;
				font-family: PingFangSC, PingFang SC;
				font-weight: 400;
				color: #EF5233;
				line-height: 30rpx;
		
				text {
					color: #656667;
				}
			}
		}
	}
}
</style>
